import 'package:flutter/material.dart';
import 'package:news_f/news.dart';

class DetailPage extends StatefulWidget {
  const DetailPage({super.key});

  @override
  State<DetailPage> createState() => _DetailPageState();
}

class _DetailPageState extends State<DetailPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    Map<String, dynamic> routeParams =
        ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>;
    print(routeParams);
    News news = routeParams['item'];

    return Scaffold(
      appBar: AppBar(
        title: Text("新闻详情"),
      ),
      body: SingleChildScrollView(
        child: Column(children: [
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Text(news.title ?? ''),
          ),
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Row(
              children: [
                Text(
                  "作者：${news.author}",
                  style: TextStyle(fontSize: 12),
                ),
                Spacer(),
                Text(
                  "发布时间：${news.createTime}",
                  style: TextStyle(fontSize: 12),
                ),
              ],
            ),
          ),
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Text(
              news.content ?? '',
              style: TextStyle(fontSize: 12),
            ),
          ),
        ]),
      ),
    );
  }
}
